const {
	request
} = require('../services/request.js')



const formatDate = () => {
	
    const time = new Date();
	const year = time.getFullYear();
	const month = time.getMonth() + 1;
	const day = time.getDate();
	const hour = time.getHours();

	//返回当前时间整点时间戳
	return new Date(`${year}/${month}/${day} ${hour}:00:00`).getTime()
}

const getDeviceHistoryData = async (productId, deviceId, beginTimestamp) => {
	const res = await request('/aep_device_status/getDeviceStatusHisInPage', 'POST', 20190928013337, {}, {
		productId,
		deviceId,
		begin_timestamp:beginTimestamp,
		end_timestamp: beginTimestamp + (60 * 60 * 1000) -( 1 * 1000),
		page_size: 1
	})
	
	return res.data.deviceStatusList;
 
}


module.exports = {
	getDeviceHistoryData,
	formatDate
}
